package cn.edu.ecut.scheduling;

public class InterruptedTest {

	public static void main(String[] args) throws InterruptedException {
		
		// 使用匿名内部类继承具体类并重写其中的方法
		Thread t = new Thread() {
			@Override
			public void run() {
				System.out.println( Thread.currentThread() + " 开始执行" );
				try {
					System.out.println( Thread.currentThread() + " 要睡觉了" );
					Thread.sleep( 1440000 );
					System.out.println( Thread.currentThread() + " 睡醒了" );
				} catch ( InterruptedException e ) {
					System.out.println( Thread.currentThread() + " : 谁TM吵醒我" );
				}
				System.out.println( Thread.currentThread() + " 执行结束" );
			}
		};
		
		t.start();
		
		Thread.sleep( 3000 ); // main 线程睡眠
		
		
		// main 线程调用 t 的 interrupt方法中断了 t 线程的睡眠
		t.interrupt(); // 中断线程

	}

}
